<?php 
class SysModule extends CI_Model 
{
	const tablenames = 'sysmodule';
	var $moduleid;
	var $modulecaption;
	var $moduleindex;
	var $moduleurl;
	var $internallink;
	var $ispublish;	

	public function __construct($mid='')
	{	
		
		if($mid!='')
			$this->LookUp($mid);
	}

	function Update()
	{
		
		$this->lstupdateby=$this->loginuser['uname'];
		$this->lstupdate=date('Y-m-d H:i:s');
		
		$this->db->where('uname', $this->uname);
		return $this->db->update($this->db->dbprefix($this::tablename), $this); 
	}
	
	function Create($id)
	{	
		$this->createdby=$this->loginuser['uname'];
		$this->created=date('Y-m-d H:i:s');
		return $this->db->insert($this->db->dbprefix($this->tablename), $this); 
	}

	function LookUp($uname)
	{
		$rw= $this->Inquiry($uname);	
		if(count($rw)>0){				
			$this->moduleid=$rw['moduleid'];
			$this->modulecaption=$rw['modulecaption'];
			$this->moduleindex=$rw['moduleindex'];
			$this->moduleurl=$rw['moduleurl'];
			$this->internallink=$rw['internallink'];
			$this->ispublish=$rw['ispublish'];			
		}
		else{
			return false;
		}
	}

	function Delete($id)
	{
		$this->db->where_in('uname', $id);
		return $this->db->delete($this->db->dbprefix($this->tablename)); 		
	}


	public function Inquiry($mid = false,$order=false)
	{	
	
		if($mid)
			$this->db->where('moduleid',$mid);		

		if($order)
			$this->db->order_by($order);
		else
			$this->db->order_by('modulid');
			
		$query = $this->db->get($this->db->dbprefix(self::tablenames));		
				
		if ($mid === false){					
			return $query->result_array();
		}
		else{			
			return $query->row_array();
		}
	} 

}



?>



